﻿using System;
using System.Collections.Generic;
using System.Text;
using DeepHash.Document;
using DeepHash.Document.Format;
using DeepHash.CommandParser;

namespace DeepHash.Run
{
    class OfflineCompareCommand : CommandBase
    {
        public OfflineCompareCommand()
            : base("offline")
        {
        }

        private string _path1 = string.Empty;
        [CommandParameter("path1")]
        public string Path1
        {
            get { return _path1; }
            set { _path1 = value; }
        }

        private string _path2 = string.Empty;
        [CommandParameter("path2")]
        public string Path2
        {
            get { return _path2; }
            set { _path2 = value; }
        }

        private string _basePath1 = string.Empty;
        private string _basePath2 = string.Empty;

        [CommandParameter("basepath1")]
        public string BasePath1
        {
            get { return _basePath1; }
            set { _basePath1= value; }
        }

        [CommandParameter("basepath2")]
        public string BasePath2
        {
            get { return _basePath2; }
            set { _basePath2 = value; }
        }

        public override void Execute()
        {
            TextDocumentFormatter textFormatter1 = new TextDocumentFormatter ();
            textFormatter1.BasePath = this.BasePath1;
            VerificationDocument doc1 = VerificationDocument.LoadFromFile(this.Path1,
                textFormatter1);
            TextDocumentFormatter textFormatter2 = new TextDocumentFormatter();
            textFormatter2.BasePath = this.BasePath2;
            VerificationDocument doc2 = VerificationDocument.LoadFromFile(this.Path2,
                textFormatter2);

            DocumentComparer comparer = new DocumentComparer(doc1, "path1", doc2, "path2");
            comparer.Compare();
        }
    }
}
